package com.atguigu.servicevod.controller;

import com.atguigu.commonutils.result.R;
import com.atguigu.servicevod.service.VodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author kabuda
 * @create 2023-05-09 17:30
 */
@RestController
@RequestMapping("/eduvod/video")
public class VodController {
    @Autowired
    private VodService vodService;
    @PostMapping("/upload")
    public R upload(MultipartFile file){
        String videoId=vodService.uploadVideo(file);
        return R.ok().data("videoId",videoId);
    }
    @DeleteMapping("/delete/{videoSourceId}")
    public R delete(@PathVariable("videoSourceId") String videoSourceId){
        vodService.deleteVideo(videoSourceId);
        return R.ok();
    }
    @GetMapping("/getAuth/{videoSourceId}")
    public R getAuth(@PathVariable("videoSourceId") String videoId){
       String auth= vodService.getAuth(videoId);
        return R.ok().data("auth",auth);
    }
}
